﻿using System;
using System.Collections.Generic;

using System.Text;

namespace Sharp3DMath.Strokes
{
    public class StrokeFeaturesBase
    {
        #region Private Attribute
        double pch2_ach;
        double her_wer;
        double tl_pch;
        double ach_aer;
        double alq_ach;
        double plt_pch;
        double alt_ach;
        double alq_aer;
        double plq_pch;
        double alt_alq;
        double alt_aer;
        double hollowness;
        #endregion

        #region Public Attribute
        public double Pch2_Ach { get { return pch2_ach; } }
        public double Pch2_Ach4PI { get { return pch2_ach / (4*Math.PI); } }
        public double Her_Wer { get { return her_wer; } }
        public double Tl_Pch { get { return tl_pch; } }
        public double Ach_Aer { get { return ach_aer; } }
        public double Alq_Ach { get { return alq_ach; } }
        public double Plt_Pch { get { return plt_pch; } }
        public double Alt_Ach { get { return alt_ach; } }
        public double Alq_Aer { get { return alq_aer; } }
        public double Plq_Pch { get { return plq_pch; } }
        public double Alt_Alq { get { return alt_alq; } }
        public double Alt_Aer { get { return alt_aer; } }
        public double Hollowness { get { return hollowness; } }
        #endregion

        public void ComputeFeatures(GlobalGeometricFeatureGenerator strokeFeature)
        {
            if (strokeFeature.Aer == 0)// perfect line
            {
                pch2_ach = 0;
                her_wer = 0;
                tl_pch = strokeFeature.Tl / strokeFeature.Pch;
                ach_aer = 0;
                alq_ach = 0;
                plt_pch = 0;
                alt_ach = 0;
                alq_aer = 0;
                plq_pch = 0;
                alt_alq = 0;
                alt_aer = 0;
            }
            else
            {
                if (strokeFeature.Alq == 0) //perfect triangle
                {
                    alt_alq = 1;
                    alq_ach = strokeFeature.Alt / strokeFeature.Ach;
                    alq_aer = strokeFeature.Alt / strokeFeature.Aer;
                }
                else
                {
                    alt_alq = strokeFeature.Alt / strokeFeature.Alq;
                    alq_ach = strokeFeature.Alq / strokeFeature.Ach;
                    alq_aer = strokeFeature.Alq / strokeFeature.Aer;
                }
                pch2_ach = (strokeFeature.Pch * strokeFeature.Pch) / strokeFeature.Ach;
                her_wer = Math.Min(strokeFeature.Her, strokeFeature.Wer) / Math.Max(strokeFeature.Her, strokeFeature.Wer);
                tl_pch = strokeFeature.Tl / strokeFeature.Pch;
                ach_aer = strokeFeature.Ach / strokeFeature.Aer;

                plt_pch = strokeFeature.Plt / strokeFeature.Pch;
                alt_ach = strokeFeature.Alt / strokeFeature.Ach;

                plq_pch = strokeFeature.Plq / strokeFeature.Pch;
                alt_aer = strokeFeature.Alt / strokeFeature.Aer;
            }
            hollowness = strokeFeature.Hollowness;
        }
        public void ComputeFeatures(GlobalGeometricFeature strokeFeature)
        {
            if (strokeFeature.Aer == 0)// perfect line
            {
                pch2_ach = 0;
                her_wer = 0;
                tl_pch = strokeFeature.Tl / strokeFeature.Pch;
                ach_aer = 0;
                alq_ach = 0;
                plt_pch = 0;
                alt_ach = 0;
                alq_aer = 0;
                plq_pch = 0;
                alt_alq = 0;
                alt_aer = 0;
            }
            else
            {
                if (strokeFeature.Alq == 0) //perfect triangle
                {
                    alt_alq = 1;
                    alq_ach = strokeFeature.Alt / strokeFeature.Ach;
                    alq_aer = strokeFeature.Alt / strokeFeature.Aer;
                }
                else
                {
                    alt_alq = strokeFeature.Alt / strokeFeature.Alq;
                    alq_ach = strokeFeature.Alq / strokeFeature.Ach;
                    alq_aer = strokeFeature.Alq / strokeFeature.Aer;
                }
                pch2_ach = (strokeFeature.Pch * strokeFeature.Pch) / strokeFeature.Ach;
                her_wer = Math.Min(strokeFeature.Her, strokeFeature.Wer) / Math.Max(strokeFeature.Her, strokeFeature.Wer);
                tl_pch = strokeFeature.Tl / strokeFeature.Pch;
                ach_aer = strokeFeature.Ach / strokeFeature.Aer;

                plt_pch = strokeFeature.Plt / strokeFeature.Pch;
                alt_ach = strokeFeature.Alt / strokeFeature.Ach;

                plq_pch = strokeFeature.Plq / strokeFeature.Pch;
                alt_aer = strokeFeature.Alt / strokeFeature.Aer;
            }
            hollowness = strokeFeature.Hollowness;
        }
    }
}
